package com.sys.service.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.sys.dao.impl.FileDaoImpl;
import com.sys.domain.File;
import com.sys.service.FileService;

public class FileServiceImpl implements FileService {

	@Override
	public List<File> getDownLoadRecord(String userId) throws SQLException {
		return null;
	}
	
	public void sortFiles(List<File> learn, List<File> play, List<File> ide,List<File> office)
			throws SQLException {
		List<File> files = new FileDaoImpl().findAllFileThatCanBeDownload();
		for(File eFile:files) {
			if(eFile.getFileType().equals("Learn")){
				learn.add(eFile);
			}else if (eFile.getFileType().equals("Play")) {
				play.add(eFile);
			}else if (eFile.getFileType().equals("IDE")) {
				ide.add(eFile);
			}else {
				office.add(eFile);
			}
		}
	}
	
	@Override
	public List<File> getInfoFromBeginToEnd(List<File> file, Integer begin, Integer end) {
		List<File> fileInfo = new ArrayList<>();
		for(int i = begin; i < end; i++) {
			fileInfo.add(file.get(i));
		}
		return fileInfo;
	}
}
